package com.beiding.businessplatform.request;

import org.springframework.http.HttpStatus;

//响应类
public class R {

    public static final R OK = R.ok();

    //状态码
    private int status;

    //提示信息
    private String msg;

    private Object body;

    public R(int status, String msg, Object body) {
        this.status = status;
        this.msg = msg;
        this.body = body;
    }

    public int getStatus() {
        return status;
    }

    public String getMsg() {
        return msg;
    }

    public Object getBody() {
        return body;
    }

    public static R ok() {
        return new R(HttpStatus.OK.value(), null, null);
    }

    public static R ok(Object body) {
        return new R(HttpStatus.OK.value(), null, body);
    }

    public static R ok(String msg, Object body) {
        return new R(HttpStatus.OK.value(), msg, body);
    }


    public static R warning(String msg) {
        return new R(320, msg, null);
    }


    public static R error(String msg) {
        return new R(HttpStatus.INTERNAL_SERVER_ERROR.value(), msg, null);
    }

}
